package edu.whut.mall.portal.service.impl;

import edu.whut.mall.mapper.UserMapper;
import edu.whut.mall.model.User;
import edu.whut.mall.model.UserExample;
import edu.whut.mall.portal.service.IUserService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * @program: d9lab-mall
 * @description: 用户接口实现类
 * @author: Wayne
 * @create: 2020-05-15 14:41
 **/
@Service
@RequiredArgsConstructor
public class UserServiceImpl implements IUserService {

    private final UserMapper userMapper;


    @Override
    public int insertUserSelective(User user) {
        return userMapper.insertSelective(user);
    }

    @Override
    public int updateUserSelective(String openId, User user) {
        UserExample userExample = new UserExample();
        userExample.createCriteria().andOpenIdEqualTo(openId);
        return userMapper.updateByExampleSelective(user, userExample);
    }

    @Override
    public User selectUserByOpenId(String openId) {
        return userMapper.selectByOpenId(openId);
    }
}
